home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <winb.h>
- #include <te.h>
- #include <fntb.h>
- #include <gui.h>
- #include <egb.h>
- #include <guidbg.h>
-
- #include <mos.h>
- #include <eintm.h>
- #include <kh.h>
-
- char *guiEgbPtr ; /* EGB のワークアドレス */
-
- int iconDialogID = -1 ;
- int iconQuitIconID = -1 ;
- int barIconID = -1 ;
-
- unsigned int beforeTime,afterTime;
-
- int quitFuncRet = ILLEGAL_FUNCTION ;
-
- /*= リジューム用設定=================================================*/
- FRAME RSM_FRAME;
- char RSMID[]="%%% burden2 %%%";
- char RSMTITLE[]= "burden2 By 機拡";
-
- int userFunc(apliId, messId, info, data)
- int apliId;
- int messId;
- int info;
- int data;
- {
- register int ret;
-
- ret = ILLEGAL_FUNCTION;
-
- switch(messId)
- {
- case GM_QUIT :
- MMI_SendMessage(iconQuitIconID,MM_EXEC,2,0,0);
- ret = quitFuncRet ;
- ret = NOERR ;
- break;
- }
-
- return(ret);
- }
-
- void main()
- {
- static MMICTRL mmi ={
- SCREEN16|SCREENIGNORE, // ページ0側解像度
- SCREENUNUSED, // ページ1側解像度
- 0, // 書き込みページ
- SCREENAVAILABLE, // 表示ページ
- 0, // 表示プライオリティ
- SCREENAVAILABLE, // 色数
- SCREENEXPAND, // VRAMの横の長さ
- 0, // メモリ領域の大きさ
- NULL, // メモリ領域のアドレス
- 0, // ユーザ領域の大きさ
- NULL, // ユーザ領域のアドレス
- 0, 0, // 画面枠 lupx,lupy
- 0, 0, // rdwx,rdwy
- -16384, -16384, // 移動枠 lupx,lupy
- 16383, 16383, // rdwx,rdwy
- 15, // 白色
- 8, // 黒色
- 7, // 灰色
- 6 // 反転色
- };
-
- extern int APL_init() ;
- extern int APL_end() ;
-
- /* 初期化処理 */
- if (MMI_Open( &mmi ) == NOERR)
- {
- /* 初期化に成功すればメインループに入る. */
- if (APL_init() == NOERR)
- {
- MMI_ExecSystem() ;
- APL_end();
- }
- }
-
- /* 終了処理 */
- MMI_Close() ;
-
- }
-
- int APL_init()
- {
- extern MMIINIT initDataGUI ;
-
- register int ret ;
-
- /* EGB ワークアドレスの取得. */
- guiEgbPtr = MMI_GetEgbPtr() ;
-
- /* ユーザアイコン設定 */
- extern unsigned char *iconTbl[];
- extern int iconMaxId;
- MMI_SetIconTable(iconTbl, iconMaxId);
-
- /* ハイパ型部品の初期化 */
- if ((ret = MMI_initHyper()) < 0)
- return ret ;
- /* ダイアログ型部品の初期化 */
- if ((ret = MMI_initDialogL40()) < 0)
- return ret ;
- /* ボタン型部品の初期化 */
- if ((ret = MMI_initButtonL40()) < 0)
- return ret ;
- /* アイコンボタン型部品の初期化 */
- if ((ret = MMI_initIconL40()) < 0)
- return ret ;
-
- /* 背景データの初期化 */
-
- /* データの登録 */
- if ((ret = MMI_Init(&initDataGUI)) < 0)
- return ret ;
-
- // Tmenuにパレットを合わせる
- KH_initGuiColor();
-
- /*----------------------------------------------------------------*/
- /* リジューム読み込み (※のついた処理は必ず行ってください) */
- /*----------------------------------------------------------------*/
- char work[RSMWORKSIZE]; // リジュームマネージャのワークエリア
- char buf[250];
- char *ptr;
- int size, x, y;
- HYPER hyp;
-
- // リジュームマネージャの初期化
- EIN_rsmInit( work, RSMID );
- // 読み込みバッファ設定
- EIN_rsmBufSet( work, buf, 250 );
- // リジューム情報読み込み
- size = EIN_rsmLoad( work );
- #ifdef DEBUG
- printf(" resume size(%d)\n",size);
- #endif
- if ( size > 0 ){
- // 表示位置
- if ( ((ptr = strstr(buf,"\nPANEL: ")) != NULL ) &&
- (sscanf(ptr,"\nPANEL: %d %d\n", &x, &y) > 1 ) ){
- // 枠座標を得る
- MMI_SendMessage( iconDialogID, MM_GETHYPER, 1, &hyp );
- RSM_FRAME.lupx = x;
- RSM_FRAME.lupy = y;
- RSM_FRAME.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
- RSM_FRAME.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
- #ifdef DEBUG
- printf("PANEL: move to (%d,%d)\n", x, y);
- #endif
- MMI_SendMessage( iconDialogID, MM_MOVE, 1, &RSM_FRAME ) ;
- }
- } else {
- #ifdef DEBUG
- printf("Can't find resume file.\n");
- #endif
- }
-
- /* 背景を表示する */
- MMI_SendMessage(MMI_GetBaseObj(), MM_SHOW, 0) ;
-
- MMI_SendMessage(MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc);
- MMI_CallMessage(MMI_GetApliId(), GM_TITLE, (int)RSMTITLE, 0);
-
- extern void userIdleTask();
- MMI_SetIdleTaskFunc( userIdleTask );
- beforeTime = MOS_getTime();
- userIdleTask();
-
- return NOERR ;
- }
-
- int APL_end()
- {
- /*===================================================================*/
- /* リジューム情報更新 (※がついた処理は必ず行って下さい) */
- /*===================================================================*/
- char work[RSMWORKSIZE];
- char buf[250];
- char aplpath[128];
- HYPER hyp;
- register int ret;
-
- // 枠座標を得る
- MMI_SendMessage( iconDialogID, MM_GETHYPER, 1, &hyp );
-
- // 移動していたらセーブ
- if ( (RSM_FRAME.lupx != hyp.fr.lupx) ||
- (RSM_FRAME.lupy != hyp.fr.lupy) ){
- // マネージャ初期化
- EIN_rsmInit( work, RSMID );
- // バッファ設定(アプリ識別ID,更新時刻は自動設定されます)
- EIN_rsmBufSet( work, buf, 250 );
- // アプリディレクトリ保存
- MMI_CallMessage( MMI_GetApliId(), GM_QUERYID, QM_PATH, (int)aplpath );
- EIN_rsmBufPrintf( work, "APLPATH: %s", aplpath );
- // アプリ名保存
- EIN_rsmBufPrintf( work, "TITLE: %s", RSMTITLE );
- // コメント保存
- EIN_rsmBufCat( work, "COMMENT: アイドルタスクの負荷を測りまっす");
- // アイコン位置保存
- EIN_rsmBufPrintf( work, "PANEL: %d %d", hyp.fr.lupx, hyp.fr.lupy );
- // バッファ終端(^A)設定
- EIN_rsmBufTail( work );
- // バッファをセーブ
- ret = EIN_rsmSave( work );
- #ifdef DEBUG
- printf(" resume save size(%d) ptr:(%d,%d)\n",ret, hyp.fr.lupx, hyp.fr.lupy);
- #endif
- }
-
- return NOERR;
- }
-
- void userIdleTask(void)
- {
- register unsigned int i;
-
- afterTime = MOS_getTime();
-
- i = afterTime - beforeTime;
-
- if(i>31) i = 545 ;
- else i += 513 ;
-
- MMI_SendMessage(barIconID,MM_SETSHAPE,1,i);
- MMI_SendMessage(barIconID,MM_SHOW,0);
-
- beforeTime = afterTime;
-
- return ;
- }
-
- /* initDataGUI:iconQuitIconID:MJ_ICONL40の呼び出し関数 */
- int iconQuitFunc(kobj, messId, argc, pev, trigger)
- int kobj ;
- int messId ;
- int argc ;
- EVENT *pev ;
- int trigger ;
- {
- MMI_SetHaltFlag(TRUE);
- quitFuncRet = NOERR ;
-
- return NOERR ;
- }
-
-